package com.gin.no_gay_alliance.adpter.reply;

import android.content.Context;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;

import com.gin.nga.response.field.Gift;
import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.databinding.ItemGiftBinding;
import com.gin.no_gay_alliance.utils.ImageUtils;

import java.util.List;
import java.util.Locale;

/**
 * 礼物适配器
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/8/24 17:01
 **/
public class GiftAdapter extends BaseBindingRecyclerViewAdapter<ItemGiftBinding, Gift> {

    public GiftAdapter(@NonNull Context context, @NonNull List<Gift> data) {
        super(context, data);
    }

    @Override
    protected void onBindViewHolder(ViewHolder<ItemGiftBinding> holder, @NonNull ItemGiftBinding b, int position, Gift item) {
        // 礼物图标
        ImageUtils.loadUserAvatar(context, item.getUrl(), b.iv);
        // 礼物数量
        b.tvCount.setText(String.format(Locale.CHINA, "x %d", item.getCount()));
    }

    @NonNull
    @Override
    protected ItemGiftBinding buildBinding(LayoutInflater inflater) {
        return ItemGiftBinding.inflate(inflater);
    }
}

